<template>
  <section>
    <div class="wrapper">
      <h2>{{userInfo.status == 0 ? "未审核": userInfo.status == 1 ? "通过初审": userInfo.status == 2 ? "通过终审": userInfo.status == 3 ? "未通过": userInfo.status}}</h2>

      <van-cell title="照片" is-link>
        <template #default>
          <van-uploader
            v-model="fileList"
            :max-count="1"
            :deletable="false"
            :max-size="500 * 1024"
          />
        </template>
      </van-cell>

      <van-field
        v-model="userInfo.userName"
        label="姓名"
        input-align="right"
        disabled
        is-link
      />

      <van-field
        v-model="userInfo.userSex"
        label="性别"
        input-align="right"
        disabled
        is-link
      />

      <van-field
        v-model="userInfo.department"
        label="工作单位"
        input-align="right"
        disabled
        is-link
      />

      <van-field
        v-model="userInfo.xgno"
        label="工号"
        input-align="right"
        disabled
        is-link
      />

      <van-field
        v-model="userInfo.workTime"
        label="参加工作时间"
        placeholder=""
        input-align="right"
        disabled
        is-link
        @click="showDatePicker = true"
      />

      <van-field
        v-model="userInfo.idcard"
        label="身份证号"
        placeholder=""
        input-align="right"
        disabled
        is-link
      />

      <van-field
        v-model="userInfo.userAddress"
        label="家庭住址"
        placeholder=""
        input-align="right"
        disabled
        is-link
      />

      <van-field
        v-model="userInfo.homeTelephone"
        type="tel"
        label="住宅电话"
        placeholder=""
        input-align="right"
        disabled
        is-link
      />

      <van-field
        v-model="userInfo.mobileTelephone"
        type="tel"
        label="手机号码"
        placeholder=""
        input-align="right"
        disabled
        is-link
      />
    </div>
  </section>
</template>
<script>
import api from "@/data/api/index.js";

import Vue from "vue";
import { Field } from "vant";
import { Cell } from "vant";
import "vant/lib/index.css";

Vue.use(Field);
Vue.use(Cell);

export default {
  data() {
    return {
      //用户信息
      userInfo: {
        userId: "",
        userName: "",
        userSex: "",
        department: "",
        xgno: "",
        workTime: "",
        idcard: "",
        userAddress: "",
        mobileTelephone: "",
        homeTelephone: "",
        unionId: "",
        unionName: "",
        status: "0",
      },
      fileList: [],
      photoUrl: {},
      urlData: {}
    };
  },
  mounted() {
    this.urlData = JSON.parse(this.$route.query.tdata);
    this.getUserInfo();
  },
  methods: {
    // 获取当前用户信息
    getUserInfo() {
      api.myHelpListDetail(this.urlData.id).then(res=>{
        // 性别
        if(res.userSex!='男' && res.userSex!='女'){
          res.userSex=res.userSex == "01" ? "男" : "女";
        }

        this.userInfo = res
        this.userInfo.workTime=this.userInfo.workTime.split(" ")[0]
        this.photoUrl.url = 'https://i.hunnu.edu.cn/ums/avatar/' + res.xgno;
        this.photoUrl.isImage = true;
        this.fileList.push(this.photoUrl);
      })
    },
  },
};
</script>
<style lang="scss" scoped>
section {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  min-height: calc(100% - 40px);
}
.wrapper {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 4px;
  font-size: 16px;
  h2 {
    height: 50px;
    line-height: 50px;
    margin: 0 -4px 10px;
    color: #fff;
    font-size: 18px;
    font-weight: normal;
    text-align: center;
    background: linear-gradient(to right, #FEB692,#EA5455);
  }
}
</style>
